package com.example.scorer

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.SavedStateViewModelFactory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import com.example.scorer.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    private lateinit var mViewModel: MyViewModel
    var binding: ActivityMainBinding ?= null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
//        setContentView(R.layout.activity_main)
        //绑定视图
        binding=DataBindingUtil.setContentView(this,R.layout.activity_main)
        mViewModel=ViewModelProvider(this).get(MyViewModel::class.java)
        //绑定数据
        binding!!.data=mViewModel
        //绑定生命周期
        binding!!.lifecycleOwner = this

    }

    companion object {
        const val SCOREA:String="scoreA"
        const val SCOREB:String="scoreB"
        const val LIST:String="List"
    }
}
